﻿using FDStudio.Core.Entities;
using FDStudio.Core.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace FDStudio.Core.Caches
{
    /*
     CreatedOn: 2018-02-08
     CreatedBy: Jackie Lee(天宇遊龍)
     */
    /// <summary>
    /// 缓存上下文接口
    /// </summary>
    public interface ICacheContext
    {
        /// <summary>
        /// 缓存类型
        /// </summary>
        CacheType CacheType { get; }

        /// <summary>
        /// 切换连接
        /// </summary>
        /// <param name="name"></param>
        /// <param name="redisStorageType"></param>
        void Switch(string name);

        /// <summary>
        /// 切换redis库
        /// </summary>
        /// <param name="databaseIndex"></param>
        void SwitchDatabase(int databaseIndex);

        /// <summary>
        ///  String
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expires"></param>
        void Set(string key, string value, int expires = 0);

        string Get(string key);

        /// <summary>
        /// Hash
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="field"></param>
        /// <param name="model"></param>
        /// <param name="expires"></param>
        void Set<T>(string key, string field, T model, int expires = 0);

        T Get<T>(string key, string field);

        /// <summary>
        ///  Object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="model"></param>
        /// <param name="expires"></param>
        void Set<T>(string key, T model, int expires = 0);

        T Get<T>(string key);

        /// <summary>
        /// List
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="values"></param>
        //void Set<T>(string key, IList<T> values, int expires = 0);

        void Remove(string key);

        void Remove(string key, string field);

        void Remove<T>(string key, T model);
    }
}
